package com.mingqijia.gassafety.job.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mingqijia.gassafety.db.entity.WarningRecord;
import com.mingqijia.gassafety.db.mapper.WarningRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author zhangfei
 * @version 1.0.0
 * @ClassName WarningRecordServiceImpl.java
 * @Description
 * @createTime 2022年03月10日
 */
@Service
@Slf4j
public class WarningRecordServiceImpl {


    @Autowired
    WarningRecordMapper warningRecordMapper;

    public  void updateRecordStatus(String imei, String taskIdentificationCode,int status ) {
        WarningRecord warningRecord = new WarningRecord();
        warningRecord.setIMEI(imei);
        warningRecord.setTaskIdentificationCode(taskIdentificationCode);
//        warningRecord.setSendResult(status);
        warningRecord.setEndTime(new Date());
        warningRecord.setStatus(status);
        QueryWrapper<WarningRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().or()
                .eq(WarningRecord::getTaskIdentificationCode,taskIdentificationCode);
        warningRecordMapper.update(warningRecord,queryWrapper);
    }
}
